import request from '@/api/utils/request'
import type {
  EmailDTO,
  ManageUserDTO,
  RegisterDTO,
  LoginDTO,
  PostDTO,
} from './types/user'

// 用户发送邮件
export const useUserSendEmailApi = (data: EmailDTO) => {
  return request.post('/user/sendEmail', data)
}

// 用户发送验证码
export const useUserSendCodeApi = (data: EmailDTO) => {
  return request.post('/user/sendCode', data)
}

// 用户搜索
export const useUserSearchApi = (data: ManageUserDTO) => {
  return request.post('/user/searchUser', data)
}

// 用户注册
export const useUserRegisterApi = (data: RegisterDTO) => {
  return request.post('/user/register', data)
}

// 普通用户修改帖子
export const useUserModifyPostByCommonApi = (
  data: PostDTO,
) => {
  return request.post('/user/modifyPostByCommon', data)
}

// 用户登出
export const useUserLogoutApi = () => {
  return request.post('/user/logout')
}

// 用户登录
export const useUserLoginApi = (data: LoginDTO) => {
  return request.post('/user/login', data)
}

// 删除用户
export const useUserDeleteApi = (data: ManageUserDTO) => {
  return request.post('/user/deleteUser', data)
}
export const useUserDeletePostByAdminApi = (
  data: PostDTO,
) => request.post('/user/deletePostByAdmin', data)
// 版主删除帖子
export const useUserDeletePostByModeratorApi = (
  data: PostDTO,
) => {
  return request.post('/user/deletePostByModerator', data)
}

// 普通用户删除帖子
export const useUserDeletePostByCommonApi = (
  data: PostDTO,
) => {
  return request.post('/user/deletePostByCommon', data)
}

// 创建用户
export const useUserCreateApi = (data: ManageUserDTO) => {
  return request.post('/user/createUser', data)
}

// 版主创建帖子
export const useUserCreatePostByModeratorApi = (
  data: PostDTO,
) => {
  return request.post('/user/createPostByModerator', data)
}

// 普通用户创建帖子
export const useUserCreatePostByCommonApi = (
  data: PostDTO,
) => {
  return request.post('/user/createPostByCommon', data)
}

// 管理员创建帖子
export const useUserCreatePostByAdminApi = (
  data: PostDTO,
) => {
  return request.post('/user/createPostByAdmin', data)
}

// 获取用户经验值
export const useUserGetExpApi = () => {
  return request.get('/user/getUserExp')
}

// 获取所有用户
export const useUserGetAllApi = () => {
  return request.get('/user/getAllUser')
}

// 检测用户是否登录
export const useUserCheckLoginStatusApi = () => {
  return request.get('/user/checkLoginStatus')
}

export const useUserGetMyCommentList = () => {
  return request.get('/user/getMyCommentList')
}

